{extend name="layout/base" /}
<!-- 标题 -->
{block name="title"}站点管理{/block}

<!-- CSS -->
{block name="css"}{/block}

<!-- 具体内容 -->
{block name="content"}
<h2 class="header-dividing">站点管理 <small>Site list</small></h2>
<div class="navbar navbar-default navbar-content">
    <div class="collapse navbar-collapse">
        <ul class="nav navbar-nav">
            {if(check_auth('site-create'))}<li><a data-toggle="modal" data-target="#modal-create" data-action="{:url('@admin/site/save')}"> <i class="icon icon-plus"></i> 新建站点</a></li>{/if}
        </ul>
        <!-- 导航中的表单 -->
        <form class="navbar-form navbar-left" role="search" action="{:url('@admin/site')}" method="get">
            <input type="text" class="form-control" placeholder="搜索" name="keywords" value="{$keywords}">
            <button type="submit" class="btn btn-default">搜索</button>
        </form>
    </div>
</div>
<div class="alert alert-danger mb10" id="alert-note" style="display: none;">
    <p><b>注意：</b> 您尚未设置默认首页，默认首页必须设置，未设置将会影响网站打开。</p>
</div>
<div class="panel">
    <table class="table datatable table-fixed" data-checkable="true" data-check-by-click-row="false">
        <thead>
            <tr>
                <th width="50" data-width="50">ID</th>
                <th width="100" data-width="100" class="text-center">排序</th>
                <th width="150" data-width="150">站点名称</th>
                <th width="80" data-width="80">标识</th>
                <th>站点描述</th>
                <th width="200" data-width="200">域名</th>
                <th width="80" data-width="80" class="text-center">首页</th>
                <th width="80" data-width="80" class="text-center">栏目</th>
                <th width="80" data-width="80" class="text-center">参数</th>
                <th width="80" data-width="80" class="text-center">修改</th>
                <th width="80" data-width="80" class="text-center">删除</th>
            </tr>
        </thead>
        <tbody>
            {assign name="site_default" value="0" /}
            {volist name="list" id="vo"}
            <tr data-id="{$vo['site_id']}">
                <td>{$vo['site_id']}</td>
                <td class="text-center"><input type="text" class="form-control sort text-center" data-url="{:url('@admin/site/sort')}" data-old-sort="{$vo['site_sort']}" data-id="{$vo['site_id']}" value="{$vo['site_sort']}"></td>
                <td>{$vo['site_name']}</td>
                <td>{$vo['site_mark']}</td>
                <td>{$vo['site_desc']}</td>
                <td>{$vo['site_domain']}</td>
                <td class="text-center">
                {if ($vo['site_default'] == 1)}
                    {assign name="site_default" value="1" /}
                    <i class="icon icon-check text-success"></i>
                {else /}
                    <a data-url="{:url('@admin/site/home','id='.$vo['site_id'])}" title="将该站设为主页" class="set-home"><i class="icon icon-times text-danger"></i></a>
                {/if}
                </td>
                <td class="text-center">{if(check_auth('site-column'))}<a href="{:url('@admin/site/column','siteid='.$vo['site_id'])}">栏目</a>{/if}</td>
                <td class="text-center">{if(check_auth('site-param'))}<a href="{:url('@admin/site/param', 'siteid='.$vo['site_id'])}">参数</a>{/if}</td>
                <td class="text-center">{if(check_auth('site-edit'))}<a data-toggle="modal" data-target="#modal-create" data-url="{:url('@admin/site/edit', 'id='.$vo['site_id'])}" data-action="{:url('@admin/site/update')}">修改</a>{/if}</td>
                <td class="text-center">{if(check_auth('site-delete'))}<a class="delete" data-url="{:url('@admin/site/delete','id='.$vo['site_id'])}">删除</a>{/if}</td>
            </tr>
            {/volist}
        </tbody>
    </table>
    {empty name="list"}
    <div class="mb20 mt20 text-center">
        {if ($keywords!='')}
        未搜索到 “{$keywords}” 相关的站点 &nbsp; <a href="{:url('@admin/site')}">查看全部站点</a>
        {else /}
        暂未添加站点
        {/if}
    </div>
    {/empty}
    {notempty name="list"}
    <div class="mb10 ml10">
        {if(check_auth('site-delete'))}<button class="btn btn-danger check-delete" type="button" data-url="{:url('@admin/site/delete')}">删除站点</button>{/if}
    </div>
    {/notempty}
</div>
{include file="site/create" /}
{/block}



<!-- JS -->
{block name="js"}
    {load href="/static/lib/jquery/jquery.form.js"}
    {load href="/static/lib/jquery/jquery.autofill.min.js"}
    {load href="/static/lib/validator/validator.min.js"}
{/block}
{block name="jscode"}
<script type="text/javascript">
$(document).ready(function() {
    $(".set-home").click(function(event) {
        var $url = $(this).data('url');
        bootbox.confirm({
            message: "确定设置该站点为默认首页？",
            callback: function(result) {
                if (result) {
                    sxj.ajax_get($url);
                }
            }
        });
    });
    {if ($site_default == 0)} $("#alert-note").show(); {/if}
            
});
</script>
{/block}